package com.zz.controller;

import com.alibaba.fastjson.JSONObject;
import com.zz.service.ContractService;
import com.zz.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

// 合同模块 开发上量奖励模块 下载模板
@RestController
@RequestMapping("/template")
public class ContractController {

    @Autowired
    ContractService contractService;

    @PostMapping("/generatorContractTemplate")
    public ResultUtil<String> generatorContractTemplate(@RequestBody JSONObject jsonObject) {
        String contractId = jsonObject.getString("contractId");
        String operationId = jsonObject.getString("operationId");
        contractService.getDocTemplate(contractId, operationId);
        return ResultUtil.success();
    }

    @PostMapping("/marketContractTemplate")
    public ResultUtil<String> marketContractTemplate(@RequestBody JSONObject jsonObject) {
        String contractId = jsonObject.getString("contractId");
        String operationId = jsonObject.getString("operationId");
        contractService.marketContractTemplate(contractId, operationId);
        return ResultUtil.success();
    }

    @PostMapping("/incentiveTemplate")
    public ResultUtil<String> incentiveTemplate(@RequestBody JSONObject jsonObject) {
        String incentiveId = jsonObject.getString("incentiveId");
        String operationId = jsonObject.getString("operationId");
        contractService.incentiveTemplate(incentiveId, operationId);
        return ResultUtil.success();
    }

    @GetMapping("/generatorFile")
    public void generatorFile() {
        contractService.generatorFile();
    }

    @GetMapping("/test")
    public void test() {
        contractService.test();
    }
}
